Option Explicit
Sub F_Sample026()
    'Microsoft ActiveX Data Objects 2.X Library ]wޥζ
    'ոF_Data.mdb F_Tbl01
    'ոF_Data01
    Dim myCon      As New ADODB.Connection
    Dim myRst      As New ADODB.Recordset
    Dim myFileName As String
    Dim myTblName  As String
    Dim myKey      As String
    Dim mySht      As Worksheet
    Dim i          As Long
    Dim j          As Long
    myFileName = "F_Data.mdb"			'gJؼɮ
    myTblName = "F_Tbl01"        		'gJؼЪ
    myCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & ThisWorkbook.Path & "\" & myFileName & ";"
    'HSQLӧRO
    myCon.Execute "DELETE FROM " & myTblName & " WHERE s > 50"
    'ǳƨ즹
    Set mySht = Worksheets("F_Data01")		'gJƪu@
    With myRst
       'ު]w
        .Index = "PrimaryKey"
       '}Ҹƿ
        myRst.Open Source:=myTblName, ActiveConnection:=myCon, _
        CursorType:=adOpenKeyset, LockType:=adLockOptimistic, _
        Options:=adCmdTableDirect
        For i = 2 To mySht.Range("A65536").End(xlUp).Row
           'jMsO_Qn
            myKey = mySht.Cells(i, 1).Value
            If Not .EOF Then .Seek myKey
            If .EOF Then
                MsgBox "sWs"
                .AddNew
                For j = 1 To .Fields.Count
                    .Fields(mySht.Cells(1, j).Value).Value = _
                    mySht.Cells(i, j).Value
                Next j
                .Update
            Else
                MsgBox "ץJs"
                For j = 2 To .Fields.Count
                    myRst(j - 1).Value = mySht.Cells(i, j).Value
                Next
                .Update
            End If
        Next i
        .Close
    End With
    myCon.Close
    Set myRst = Nothing					'
    Set myCon = Nothing
End Sub
